<template>
	<view class="main">
		<uni-nav-bar fixed left-icon="back" title="线路选择" color="#333333" backgroundColor="#FFFFFF" :border="false" statusBar
			@clickLeft="goReturn"></uni-nav-bar>
		<view class="choose-btn" v-for="(item,index) in urls" :key="index">
			<button class="btn" @click="chooseUrl(item)">{{item.name}}</button>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				urls:[
					{name:'线路一',url:'/api'},
					{name:'线路二',url:'/doc'},
				]
			}
		},
		methods: {
			chooseUrl(item){
				uni.setStorageSync("baseUrl",item.url)
				this.$http.setBaseUrl(item.url)
				uni.showToast({
					title: '选择'+ item.name,
					icon: 'none',
					complete: () => {
						setTimeout(() => {
							uni.navigateTo({
								url:'../login'
							})
						},1000)
					}
				});
			},
			// 返回
			goReturn() {
				uni.navigateTo({
					url:'../login'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.choose-btn{
	height: 120upx;
	margin: 20upx auto;
}
</style>
